import 'package:flutter/material.dart';
import 'package:photo_view/photo_view.dart';
class AnimatedHeroPage extends StatefulWidget {
  final Map arguments;

  const AnimatedHeroPage({super.key, required this.arguments});

  @override
  State<AnimatedHeroPage> createState() => _AnimatedHeroPageState();
}

class _AnimatedHeroPageState extends State<AnimatedHeroPage> {
  @override
  Widget build(BuildContext context) {
    final String imageUrl = widget.arguments['imageUrl'];
    final String title = widget.arguments['title'];
    final int index = widget.arguments['index'];
    return GestureDetector(
      onTap: () {
        Navigator.pop(context);
      },
      child: Scaffold(
        backgroundColor: Colors.black,
        body: Stack(
          children: [
            Center(
              child: AspectRatio(
                aspectRatio: 1,
                child: Hero(tag: imageUrl, child: ClipRRect(
                  borderRadius: BorderRadius.circular(12),
                  child: PhotoView(imageProvider: NetworkImage(imageUrl))
                ),),
              ),
            ),
            Positioned(
              bottom: 40,
              left: 0,  // 左右都设为0，让宽度撑满屏幕
              right: 0,
              child: Padding(
                padding: const EdgeInsets.symmetric(horizontal: 20), // 两边留边距
                child: Container(
                  height: 55, // 高度可调
                  decoration: BoxDecoration(
                    color: Colors.blue, // 背景蓝色
                    borderRadius: BorderRadius.circular(14), // 圆角
                  ),
                  child: TextButton(
                    onPressed: () {
                      Navigator.pop(context, {
                        "imageUrl": imageUrl,
                        "index": index,
                      });
                    },
                    child: const Text(
                      "加入图库",
                      style: TextStyle(
                        color: Colors.white, // 字体白色
                        fontSize: 18,
                      ),
                    ),
                  ),
                ),
              ),
            )
          ],
        )
      ),
    );
  }
}
